﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Media3D;

namespace Game3D
{
    [Serializable]
    internal class GameShapeColors
    {
        /// <summary>
        /// Material of I Shape
        /// </summary>
        public static Brush I = Brushes.Cyan;
        public static Brush O = Brushes.Yellow;
        public static Brush L = Brushes.Orange;
        public static Brush S = Brushes.Red;
        public static Brush Z = Brushes.Green;
        public static Brush T = Brushes.Purple;
        public static Brush J = Brushes.Violet;

        /// <summary>
        /// Resolves the color corresponding to the shape of GameMesh.
        /// </summary>
        /// <param name="index">The index of the color.</param>
        /// <returns>Returns a Brush with the corresponding color.</returns>
        public static Brush ResolveColor(int index)
        {
            Brush value;
            switch (index)
            {
                case 0:
                    value = I;
                    break;

                case 1:
                    value = O;
                    break;

                case 2:
                    value = L;
                    break;

                case 3:
                    value = S;
                    break;

                case 4:
                    value = Z;
                    break;

                case 5:
                    value = T;
                    break;
                
                case 6:
                    value = J;
                    break;

                default:
                    value = Brushes.Black;
                    break;
            }

            return value;
        }

        /// <summary>
        /// Resolves the color corresponding to the shape of GameMesh.
        /// </summary>
        /// <param name="shapeToResolve">A Shape enumeration object for what color should be resolved.</param>
        /// <returns>Brush of the corresponding color.</returns>
        public static Brush ResolveColor(Shape shapeToResolve)
        {
            Brush value;
            switch (shapeToResolve)
            {
                case Shape.J:
                    value = J;
                    break;
                case Shape.I:
                    value = I;
                    break;
                case Shape.L:
                    value = L;
                    break;
                case Shape.O:
                    value = O;
                    break;
                case Shape.T:
                    value = T;
                    break;
                case Shape.S:
                    value = S;
                    break;
                case Shape.Z:
                    value = Z;
                    break;
                default:
                    value = Brushes.Black;
                    break;
            }

            return value;
        }

        /// <summary>
        /// Resolves the shape for given Brush.
        /// </summary>
        /// <param name="colorToResolve">For which color the shape should be returned.</param>
        /// <returns>Returns a Shape enumeration object corresponding to given color.</returns>
        public static Shape ResolveColor(Brush colorToResolve)
        {
            Shape value = Shape.Single;

            if (colorToResolve == I)
            {
                value = Shape.I;
            }
            else if (colorToResolve == J)
            {
                value = Shape.J;
            }
            else if (colorToResolve == L)
            {
                value = Shape.L;
            }
            else if (colorToResolve == O)
            {
                value = Shape.O;
            }
            else if (colorToResolve == T)
            {
                value = Shape.T;
            }
            else if (colorToResolve == Z)
            {
                value = Shape.Z;
            }
            else if (colorToResolve == S)
            {
                value = Shape.S;
            }

            return value;
        }
    }
}
